package com.lianyu507.controller;

import com.lianyu507.pojo.DtProfessionLog;
import com.lianyu507.service.DataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

/**
 * =================================
 * <p>
 * Created by Administrator on 2017/11/22.
 * <p>
 * 描述:
 */

@Controller
public class WordsCountController extends BaseController{

    @Autowired
    private DataService dataService;

    @RequestMapping(value = "/user/words",method = RequestMethod.GET)
    //@Scheduled(cron = "*/10 * * * * *")
    public void countUserWords(){
        List<DtProfessionLog> list = dataService.selectUserWord();
        if(list.size() != 0){
            dataService.insertProfession(list);
        }
    }

    /*@RequestMapping(value = "/day/words",method = RequestMethod.GET)*/
    //每15分钟触发一次
    @Scheduled(cron = "0 0,15,30,45 * * * ?")
    public void countDayWords(){
        Integer dayWords = dataService.selectDayWords();
        if(dayWords != 0 ){
            dataService.insertDayWordsToProfession(dayWords);
        }
    }
}
